<?php
require_once 'OperationsInterface.php';
require_once 'ItemFactory.php';
/**
 * This class implements the basic OperationsInterface for local file/disk operations.
 * There is another class for remote file operations which also implements the basic OperationsInterface
 * @author Sukhbir Singh Grewal
 *
 */
class LocalFileOperations implements OperationsInterface
{
	/**
	 * (non-PHPdoc)
	 * @see OperationsInterface::listContents()
	 */
	public function listContents($location)
	{
		if(!file_exists($location))
			throw new ExceptionHandler("Given foler $location not found!", -5);
		if(!is_dir($location))
			throw new ExceptionHandler("Given item $location is not a folder!", -5);
		if(!is_readable($location))
			throw new ExceptionHandler("Given foler $location cannot be read!", -5);
		$items = glob($location.DIRECTORY_SEPARATOR.'*');
		$contents = array();
		foreach ($items as $path)
		{
			$contents[] = ItemFactory::create($path);			
		}
		return $contents;
	}
	
	/**
	 * (non-PHPdoc)
	 * @see OperationsInterface::copyItem()
	 */
	public function copyItem($location, $newLocation)
	{
		
	}
	
	/**
	 * (non-PHPdoc)
	 * @see OperationsInterface::moveItem()
	 */
	public function moveItem($oldLocation, $newLocation)
	{
		
	}
	
	/**
	 * (non-PHPdoc)
	 * @see OperationsInterface::deleteItem()
	 */
	public function deleteItem($location)
	{
		
	}
	
	/**
	 * (non-PHPdoc)
	 * @see test2/OperationsInterface::newItem()
	 */
	public function newItem($location, $data)
	{
		
	}
}